/**
 * Created by jyh on 24/06/2017.
 */

import axios from 'axios'
import qs from 'qs'

var Axios = axios.create({
  responseType: 'json'
})

Axios.interceptors.response.use(function (response) {
  return response.data
}, () => Promise.reject())

export default {
  newHouseList (type, page) {
    return axios.get(`/dt/newHouse/index/${type}/${page}`)
  },
  secondHouseTop10 () {
    return axios.get('/dt/twoHouse/top10')
  },
  homePageNewsTop30 () {
    return axios.get('/dt/news/top30')
  },
  homePageNewsTop8 () {
    return axios.get('/dt/news/top8')
  },
  trendPic () {
    return axios.get('/dt/trendPic')
  },
  newHouseSearch (param) {
    return axios.post('/dt/search/newHouse', qs.stringify(param))
  },
  danTiSearch (param) {
    return axios.post('/dt/search/danti', qs.stringify(param))
  },
  newHouseDetail (id) {
    return axios.get(`/dt/newHouse/details/${id}`)
  },
  /*
   * 新房推荐Top6
   * */
  newHouseTop10 () {
    return axios.get(`/dt/newHouse/top10`)
  },
  newHouseTop6 () {
    return axios.get(`/dt/newHouse/top6`)
  },
  newHouseTop8 () {
    return axios.get(`/dt/newHouse/top8`)
  },
  /*
   * 新房推荐
   * */
  newHouseSource (page) {
    return axios.get(`/dt/newHouse/${page}`)
  },
  /*
   * 二手房推荐列表
   * */
  secondarySource (page) {
    return axios.get(`/dt/twoHouse/${page}`)
  },
  /*
   * 二手房条件搜索
   * */
  secondarySourceSearch (params) {
    return axios.post('/dt/search/twoHouse', qs.stringify(params))
  },
  secondarySourceTop6 () {
    return axios.get('/dt/twoHouse/top6')
  },
  secondarySourceTop8 () {
    return axios.get('/dt/twoHouse/top8')
  },
  secondarySourceTop10 () {
    return axios.get('/dt/twoHouse/top10')
  },
  secondarySourceDetail (id) {
    return axios.get(`/dt/twoHouse/queryDetails/${id}`)
  },
  /*
   * 单体查询
   * */
  danTiSource (page) {
    return axios.get(`/dt/${page}`)
  },
  danTiDetail (id) {
    return axios.get(`/dt/details/${id}`)
  },
  newsList () {
    return axios.get(`/dt/news`)
  },
  newsDetail (id) {
    return axios.get(`/dt/news/details/${id}`)
  },
  aboutLink () {
    return axios.get('/dt/about/index')
  },
  smsCode (phone) {
    return axios.get(`/dt/sms/code/${phone}`)
  },
  createOrder (data) {
    return axios.post('/dt/orderInfo/create', data)
  },
  isOrder (phone, id, category) {
    return axios.get(`/dt/orderInfo/${phone}/isOrder/${id}/${category}`)
  },
  twoHouseListSearch (content) {
    return axios.get(`/dt/search/banner/twoHouse/${content}`)
  },
  newHouseListSearch (content) {
    return axios.get(`/dt/search/banner/newHouse/${content}`)
  },
  danTiHouseListSearch (content) {
    return axios.get(`/dt/search/banner/danTiHouse/${content}`)
  },
  team () {
    return axios.get(`/dt/team`)
  },
  validatePic () {
    return axios.get(`/dt/validatePic`)
  },
  validate (id,code) {
    return axios.get(`/dt/validatePic/validate`+'?id='+id+'&code='+code)
  }
}
